<%@ page contentType="text/html; charset=UTF-8"%>
<%@ include file="/WEB-INF/view/system/common/head.jsp"%>
<script type="text/javascript" src="asserts/system/js/sysUser/sysUser.js"></script>
<style>

.leftTd1{
   width:24%;
 }
 .rightTd{
   width:26%;
   text-align:left;
 }

</style>
<body>
	<div class="easyui-panel" title="分组信息">
		<table class="infoTable">
			<tr>
				<td style="width:24%;">
					分组名称：
				</td>
				<td class="colrRed rightTd">
					${group.name}
				</td>
				<td style="width:24%;">
					编码：
				</td>
				<td class="colrRed rightTd" >
					${group.code}
				</td>
			</tr>
			
			<tr>
				<td style="width:24%;">
					分组描述：
				</td>
				<td colspan="3" class="alignLeft" >
					${group.descr}
				</td>
			</tr>
				
		</table>
	</div>
	<table id="dataShow">
	</table>
</body>

<script type="text/javascript">
$(document).ready(function() {
	setDataGridList();
});

var userStateListJSON = eval('(${userStateListJSON})');
var empStateListJSON = eval('(${empStateListJSON})');
//查询列表初始化
function setDataGridList() {
	$('#dataShow').datagrid({
		url:'usergroup/getUserListByGroupId.action?groupId=${group.id}',
		title:"分组用户列表",
		fitColumns:true,
		nowrap:false,
		rownumbers:true,
		showFooter:false,
		pagination:true,
		striped:true,
		singleSelect:false,
		idField:'id',
		frozenColumns:[[{
			field:'ck',
			checkbox:true
		}]],
		tools: [{iconCls: 'icon-reload',handler:function(){$('#dataShow').datagrid('reload');}}],
		toolbar:[
           <%if (SysAuthUtil.ifBtn(request, "userAdd")) {%>
			{id:'btnadd',text:'增加',iconCls:'icon-add',handler:function(){goAddUser();}},
			<%}%>
			<%if (SysAuthUtil.ifBtn(request, "userRemove")) {%>
			{id:'btnremove',text:'删除',iconCls:'icon-remove',handler:function(){removeBatch('dataShow');}},
			<%}%>
			{id:'btndisable',text:'禁用',iconCls:'icon-remove',handler:function(){disableBatch('dataShow');}}
			,{id:'btnenable',text:'启用',iconCls:'icon-add',handler:function(){enableBatch('dataShow');}}
			,'-',{id:'btnSetRole',text:'换角色',iconCls:'icon-edit',handler:function(){userRoleSetBatch('dataShow');}}
			,{id:'btnChangeGroup',text:'换分组',iconCls:'icon-edit',handler:function(){userGroupSetBatch('dataShow');}}
			,'-',{id:'btnResetPassword',text:'重置密码',iconCls:'icon-edit',handler:function(){userPwdResetBatch('dataShow');}}
			
		],
		columns:[[{field:'id',width:10,hidden:true,sortable:true}
			,{field:'code',title:"工号",width:10,sortable:true}
			,{field:'name',title:"姓名",width:20,sortable:true}
			,{field:'username',title:"登录名",width:15,sortable:true}
			,{field:'rolename',title:"角色",width:15,sortable:true}
			,{field:'userstate',title:"用户状态",width:20,sortable:true,formatter:function(val){
				if(val == '0'){
					return "正常";
				}else if(val == '1'){
					return "<span style='color:red;'>已删除</>";
				}else{
					return "<span style='color:red;'>已禁用</>";
				}
			}}
			]]
		,onDblClickRow: function (rowIndex, rowData) {goUserDetail(rowData.id);}  
		,onRowContextMenu : function(e, rowIndex, rowData) {
			e.preventDefault();
			$('#dataShow').datagrid('unselectAll');
			$('#dataShow').datagrid('selectRow', rowIndex);
			createColumnMenu(rowData);
			$('#tmenu').menu('show', {
				left : e.pageX,
				top : e.pageY
			});
		}
	});
}

var tmenu;
function createColumnMenu(rowData) {
	if (tmenu != null) {
		$("#tmenu").remove();
	}
	var menuStr = '<div id="tmenu" style="width:135px;">';
	menuStr += '<div data-options="iconCls:\'icon-edit\'" id="update">修改</div>';
	
	<%if (SysAuthUtil.ifBtn(request, "userRemove")) {%>
	menuStr += '<div data-options="iconCls:\'icon-edit\'" id="delete">删除</div>';
	<%}%>
	if (rowData.userstate == "0") {//正常
		menuStr += '<div data-options="iconCls:\'icon-edit\'"id ="forbidden">禁用</div>';
	}else if (rowData.userstate == "2") {
		menuStr += '<div data-options="iconCls:\'icon-edit\'"id ="reuse">启用</div>';
	}
	
	menuStr += '<div data-options="iconCls:\'icon-ok\'" id="detail">查看详情</div>';
	menuStr += '</div>';
	tmenu = $(menuStr).appendTo('body');
	tmenu.menu( {
		onClick : function(item) {
			if (item.id == 'forbidden'){
				updateUserState('dataShow',rowData.id,2);
			}else if (item.id == 'reuse'){
				updateUserState('dataShow',rowData.id,0);
			}else if (item.id == 'update') {
				showUserUpdate(rowData.id);
			}else if (item.id == 'detail'){
				goUserDetail(rowData.id);
			}else if(item.id == 'delete'){
				removeSingle(rowData.id,'dataShow');
			}
		}
	});
}

function goAddUser(){
	$.messager.alert('<s:text name="mes.message"/>', "已经打开新窗口添加用户，完成后点击确定刷新用户列表", 'info',function(){$('#dataShow').datagrid('reload');});
	addTab('用户添加', 'view/goUserAddWidthGroup.action?groupId='+${group.id}, '#tt', "parent.parent");
}


function goUserDetail(rowId){
	addTab('用户详情', 'view/goUserDetail.action?userId='+rowId, '#tt', "parent.parent");
}

function showUserUpdate(rowId){
	$.messager.alert('<s:text name="mes.message"/>', "已经打开新窗口修改用户，完成后点击确定刷新用户列表", 'info',function(){$('#dataShow').datagrid('reload');});
	addTab('用户修改', 'view/goUserUpdate.action?userId='+rowId, '#tt', "parent.parent");
}


/* 

function userRoleSetBatch(){
	var rows = $('#dataShow').datagrid('getSelections');
	if (rows.length == 0) {
		$.messager.alert('<s:text name="mes.message"/>', "请选择待操作的记录", 'info');
	} else {
		var param = getSelections(rows);	
		$.messager.alert('<s:text name="mes.message"/>', "已经打开新窗口设置用户角色，完成后点击确定刷新用户列表", 'info',function(){$('#dataShow').datagrid('reload');});
		addTab('用户角色设置', encodeURI(encodeURI('goUserRoleSet.action'+param)), '#tt', "parent.parent");
	}
} */
/* function userGroupSetBatch(){
	var rows = $('#dataShow').datagrid('getSelections');
	if (rows.length == 0) {
		$.messager.alert('<s:text name="mes.message"/>', "请选择待操作的记录", 'info');
	} else {
		$.messager.confirm('<s:text name="mes.message"/>', "确定要更换用户的分组吗？", function(r) {
			if (r) {
				$.messager.alert('<s:text name="mes.message"/>', "已经打开新窗口设置用户分组，完成后点击确定刷新用户列表", 'info'
					,function(){$('#dataShow').datagrid('unselectAll');$('#dataShow').datagrid('reload');});
				var param = getSelections(rows);
				addTab('用户分组设置', encodeURI(encodeURI('goUserGroupSet.action'+param)), '#tt', "parent.parent");
			}
		});
	}
} */



</script>
</html>